package com.example.demo;

import android.content.Intent;
import android.graphics.Paint;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import com.example.demo.databinding.ActivityLoginBinding;

public class LoginActivity extends BaseActivity {

    private ActivityLoginBinding binding;
    private TextView forget;
    private EditText username,  password; 

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        // 处理边缘到边缘

        // 使用视图绑定
        binding = ActivityLoginBinding.inflate(getLayoutInflater());
        binding.forget.getPaint().setFlags(Paint.UNDERLINE_TEXT_FLAG);
        username = binding.username;
        password = binding.password;
        // 使用BaseActivity的setContentView(View)方法
        setContentView(binding.getRoot());

        binding.btn1.setOnClickListener(v -> {
            String usernameText = username.getText().toString().trim();
            String passwordText = password.getText().toString().trim();
            if(TextUtils.isEmpty(usernameText) && TextUtils.isEmpty(passwordText)){
                Toast.makeText(this, "请输入用户名和密码", Toast.LENGTH_SHORT).show();
            }else{
                if(usernameText.equals("ZRAdmin")   && passwordText.equals("20072007") ){
                    startActivity(new Intent(this, SystemSettingsActivity.class));
                }else{
                    Toast.makeText(this, "密码不正确", Toast.LENGTH_SHORT).show();
                }
            }

        });

    }
}